package com.example.database;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

public class DataAccess implements guardLocalization {
	private static final String NAMESPACE = "http://service/";
	private static final String URL = 
		"http://89.68.103.162:8080/umikdb/WebServiceService?wdsl";	
	
	
	@Override
	public String[] getGuardLocalization() {
			SoapObject request = new SoapObject(NAMESPACE, "getGuardPosition");
			
			SoapSerializationEnvelope envelope = 
			new SoapSerializationEnvelope(SoapEnvelope.VER11); 
			envelope.setOutputSoapObject(request);
			HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
			Log.v("BusinessLogic", "getGuardPosition");
			try {
				androidHttpTransport.call(getSoapAction("updateGuardPosition"), envelope);
				SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
				return resultsRequestSOAP.toString().split(" ");

			} catch (Exception e) {
				e.printStackTrace();
				Log.v("BusinessLogic", "error");
				Log.v("BusinessLogic", e.getLocalizedMessage());
			}
			Log.v("BusinessLogic", "Success");
			return null;
			
	}
	private String getSoapAction(String method){
		return NAMESPACE + method;
	}

}
